<template>
    <h2>登录页面</h2>
    <table>
        <tr>
            <td>用户名</td>
            <td><input type="text" v-model="info.Uname"></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input type="password" v-model="info.Upwd"></td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: centers;">
                <input type="button" value="登录" @click="Ulogin">
            </td>
        </tr>
    </table>
    </template>
<script setup lang="ts">
import axios from 'axios';
import {ref} from 'vue'
const info=ref(
    {
        Uname:"",
        Upwd:""
    }
)
const Ulogin=()=>{
    if(info.value.Uname==""){
        alert("用户名不能为空")
        return
    }
    if(info.value.Upwd==""){
        alert("密码不能为空")
        return
    }
    axios({
        url:"https://localhost:44326/api/Lx/Ulogin",
        method:"get",
        params:{
            Uname:info.value.Uname,
            Upwd:info.value.Upwd
        }
    })
    .then(res=>{
        if(res.data==-1){
            alert("该用户不存在")
            return
        }else if(res.data==-2){
            alert("密码错误")
        }else{
            alert("登录成功")
        }

    })


}

</script>

